package com.study_security.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study_security.entity.ProjectMember;
import com.study_security.mapper.ProjectMemberMapper;
import com.study_security.service.ProjectMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, ProjectMember> implements ProjectMemberService {

    @Autowired
     private ProjectMemberMapper projectMemberMapper;

    @Override
    public boolean addMemberToProject(ProjectMember projectMember) {
        return projectMemberMapper.insert(projectMember)>0;
    }

    @Override
    public boolean projectMemberExists(Long projectId, Long memberId) {
        return projectMemberMapper.countByProjectIdMemberId(projectId, memberId) > 0;
    }

    @Override
    public boolean removeMemberFromProject(Long projectId, Long memberId) {
        return projectMemberMapper.deleteByProjectIdAndMemberId(projectId, memberId) > 0;
    }
}
